<script type="text/javascript" >
    stFacebookToolbox.load_tooltip();
    stFacebookToolbox.on_submitform('#settingForm');
    function drawVisualization() {
  	  // Create and populate the data table.
  	  var data = new google.visualization.DataTable();
  	                data.addColumn('string', 'Day');
  	                data.addColumn('number', 'Number of users');
  	                <?php if(count($chart) > 0){ foreach($chart as $row): ?>
  	                data.addRow(["<?php echo $row['day'];?>", <?php echo $row['users']; ?>]);
  	                <?php endforeach; }?>
  	  // Create and draw the visualization.
  	  new google.visualization.LineChart(document.getElementById('chart_div')).
  	      draw(data, {curveType: "function",
  	                  width: 950, height: 400,pointSize:4,
  	                  vAxis: {maxValue: 10}}
  	          );
  	}
                        function make_pdf(){
            window.open('<?php echo get_bloginfo('url');?>/pdf/page_analytics.php?pageid='+jQuery('#pageid').val()+'&month='+jQuery('#month').val()+'&year='+jQuery('#year').val()+'&type=1')
        }
            function make_excel(){
            window.open('<?php echo get_bloginfo('url');?>/excel/page_analytics.php?pageid='+jQuery('#pageid').val()+'&month='+jQuery('#month').val()+'&year='+jQuery('#year').val()+'&type=1')
        }
</script>

<div class="w100p bgl">
    <div class="w100p bgr p5b">
                <ul class="menu_right">
                      <li>
                          <a href="javascript:void(0);" onclick="stFacebookToolboxcustom.loadPage('page_analytics');" id="page_overview">Page Overview</a>
                    </li>
                    <li>
                          <a href="javascript:void(0);" onclick="stFacebookToolboxcustom.loadPage('fan_count');" id="fan_count">Fan count</a>
                    </li>
                    <li class="current">
                          <a href="javascript:void(0);" onclick="stFacebookToolboxcustom.loadPage('user_activity');" id="user_activity">User activity</a>
                    </li>
                    <li>
                          <a href="javascript:void(0);" onclick="stFacebookToolboxcustom.loadPage('viral_spread');" id="viral_spread">Viral Spread</a>
                    </li>
                    <li>
                          <a href="javascript:void(0);" onclick="stFacebookToolboxcustom.loadPage('fan_list');" id="fan_list">Fan list</a>
                    </li>
                </ul>

	<div style="padding-left:15px;">Facebook page: <select name="pageid" id="pageid" onchange = "stFacebookToolboxcustom.loadPage('user_activity_daily_change&pageid='+this.value);">
                <?php foreach($page as $row): ?>
                <option value="<?php echo $row->pageid;?>" <?php if($id == $row->pageid){echo 'selected';}?>><?php echo $row->pagename;?></option>
                <?php endforeach;?>

            </select>&nbsp;(Aggregated)</div>
		<div align="center"><a class="button add-new-h2" onclick="stFacebookToolboxcustom.loadPage('user_activity_daily_change&pageid='+jQuery('#pageid').val()+'&month='+jQuery('#month').val()+'&year='+jQuery('#year').val());" style="cursor: pointer;">
                       <b>Daily Change</b>
                    </a>&nbsp;<a class="button add-new-h2" onclick="stFacebookToolboxcustom.loadPage('user_activity&pageid='+jQuery('#pageid').val()+'&month='+jQuery('#month').val()+'&year='+jQuery('#year').val());" style="cursor: pointer;">
                       <b>Aggregated</b>
                    </a></div>
        <div id="chart_div" style="height: 400px;" align="center" ><center><br><br><br><br><br><br><br><br><br><br>NO DATA</center></div>
        <div id="date_control" align="center"><img onclick="stFacebookToolboxcustom.prev_month('user_activity_daily_change&pageid='+jQuery('#pageid').val());" style="cursor: pointer;" src="<?php echo $plugin_url;?>images/arrow_left.png">&nbsp;<span id="month_year"><?php echo $month_name[intval($month)].'&nbsp;'.$year;?></span>&nbsp;<img onclick="stFacebookToolboxcustom.next_month('user_activity_daily_change&pageid='+jQuery('#pageid').val());" style="cursor: pointer;" src="<?php echo $plugin_url;?>/images/arrow_right.png"></div>
        <input type="hidden" id="month" value="<?php echo $month;?>" />
        <input type="hidden" id="check_chart" value="<?php if(count($chart) > 0){echo '1';}else{echo '0';}?>" />
        <input type="hidden" id="year" value="<?php echo $year;?>" />
         <p></p>
		<table cellspacing="0" class="widefat" align="center">
                <thead>
                    <tr>
                        	<th style="" class="manage-column column-uid" id="date" scope="col">Date</th>
							<th style="" class="manage-column column-firstname" id="likes" scope="col">	Number of users</th>
                    </tr>
                </thead>
				<?php if(count($chart) > 0):?>
                <tbody>
                <?php $chart = array_reverse($chart);$stt = 1;foreach($chart as $row): ?>
                <tr class="bg_gray<?php echo (($stt % 2) == 0)?'1':'2'?>" id="<?php echo $row['day'];?>">
                <td>
                <?php echo str_replace('"','',$row['day']);?>
				</td>
				<td><?php echo $row['users'];?></td>
				
				</tr>
				<?php $stt++; endforeach;?>
				</tbody>
				<?php endif;?>
            </table>
    </div>
</div>
